﻿Namespace Cues.Helpers
	''' <summary>
	''' Used by list views to select the appropriate cue template to present, based on what type of cue is selected.
	''' </summary>
	''' <remarks></remarks>
	Public Class CueTypeTemplateSelector
		Inherits DataTemplateSelector

		Public Overrides Function SelectTemplate(item As Object, container As DependencyObject) As DataTemplate
			Dim element As FrameworkElement = TryCast(container, FrameworkElement)
			If element IsNot Nothing AndAlso item IsNot Nothing Then
				If TypeOf item Is Cues.Audio Then
					Return TryCast(element.FindResource("AudioCueDataTemplate"), DataTemplate)
				ElseIf TypeOf item Is Cues.Transport Then
					Return TryCast(element.FindResource("TransportCueDataTemplate"), DataTemplate)
				ElseIf TypeOf item Is Cues.Stack Then
					Return TryCast(element.FindResource("StackCueDataTemplate"), DataTemplate)
				End If

			End If

			Return Nothing
		End Function


	End Class
End Namespace
